#!/bin/bash

set -e

# bash fonts colors
red='\e[31m'
yellow='\e[33m'
green='\e[92m'
none='\e[0m'

error() { echo -e "${red}$*${none}" && exit 1; }
warning() { echo -e "${yellow}$*${none}"; }
info() { echo -e "${green}$*${none}"; }

src_dir="/home/hccluser/cann-hccl"
dst_dir="/result"

operator_dir="src/domain/collective_communication/algorithm/impl/operator"
executor_dir="src/domain/collective_communication/algorithm/impl/coll_executor/coll_all_reduce"

files=(
    "${operator_dir}/custom_all_reduce_operator.h"
    "${operator_dir}/custom_all_reduce_operator.cc"
    "${executor_dir}/coll_custom_small_all_reduce_mesh_executor.h"
    "${executor_dir}/coll_custom_small_all_reduce_mesh_executor.cc"
    "${executor_dir}/coll_custom_medium_all_reduce_mesh_executor.h"
    "${executor_dir}/coll_custom_medium_all_reduce_mesh_executor.cc"
    "${executor_dir}/coll_custom_huge_all_reduce_mesh_executor.h"
    "${executor_dir}/coll_custom_huge_all_reduce_mesh_executor.cc"
)

for file in "${files[@]}"; do
    file_path="${src_dir}/${file}"
    if [ -f "${file_path}" ]; then
        cp -i "${file_path}" "${dst_dir}"
        info "Copied: ${file_path} to ${dst_dir}"
    else
        error "No such file: ${file_path}"
    fi
done

info "All files copied successfully to ${dst_dir}"
